package com.example.mobile2030606155byl0415classwork;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.text.BreakIterator;

public class PepoleAdapter extends RecyclerView.Adapter<PepoleAdapter.ViewHolder> {
    String[] names;
    public  PepoleAdapter(String[]names){
        this.names = names;
    }
    static  class  ViewHolder extends RecyclerView.ViewHolder{
        public BreakIterator tvIemName;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
        }
    }
    @NonNull
    @Override
    public PepoleAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).
                inflate(R.layout.item_rv_main_people,parent,false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull PepoleAdapter.ViewHolder holder, int position) {
        holder.tvIemName.setText(names[position]);
    }

    @Override
    public int getItemCount() {
        return names.length;
    }
}
